package com.woniu.finance.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.woniu.finance.domain.OverdueAlarm;
import com.woniu.finance.service.IOverdueAlarmService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 客户欠费报警Controller
 * 
 * @author yy
 * @date 2023-04-04
 */
@RestController
@RequestMapping("/finance/tboverduealarm")
@Api("客户欠费报警管理")
public class OverdueAlarmController extends BaseController
{
    @Autowired
    private IOverdueAlarmService overdueAlarmService;

    /**
     * 查询客户欠费报警列表
     */
    //@PreAuthorize("@ss.hasPermi('finance:tboverduealarm:list')")
    @GetMapping("/list")
    @ApiOperation("客户欠费报警分页查询")
    public TableDataInfo list(OverdueAlarm overdueAlarm)
    {
        startPage();
        List<OverdueAlarm> list = overdueAlarmService.selectOverdueAlarmList(overdueAlarm);
        return getDataTable(list);
    }

    /**
     * 导出客户欠费报警列表
     */
    //@PreAuthorize("@ss.hasPermi('finance:tboverduealarm:export')")
    @Log(title = "客户欠费报警", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation("客户欠费报警导出")
    public void export(HttpServletResponse response, OverdueAlarm overdueAlarm)
    {
        List<OverdueAlarm> list = overdueAlarmService.selectOverdueAlarmList(overdueAlarm);
        ExcelUtil<OverdueAlarm> util = new ExcelUtil<OverdueAlarm>(OverdueAlarm.class);
        util.exportExcel(response, list, "客户欠费报警数据");
    }

    /**
     * 获取客户欠费报警详细信息
     */
    //@PreAuthorize("@ss.hasPermi('finance:tboverduealarm:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation("根据主键查询客户欠费报警")
    @ApiImplicitParam(name = "ids", value = "用户ID", required = true, dataType = "Long")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(overdueAlarmService.selectOverdueAlarmById(id));
    }

    /**
     * 新增客户欠费报警
     */
    //@PreAuthorize("@ss.hasPermi('finance:tboverduealarm:add')")
    @Log(title = "客户欠费报警", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation("添加客户欠费报警")
    public AjaxResult add(@RequestBody OverdueAlarm overdueAlarm)
    {
        return toAjax(overdueAlarmService.insertOverdueAlarm(overdueAlarm));
    }

    /**
     * 修改客户欠费报警
     */
    //@PreAuthorize("@ss.hasPermi('finance:tboverduealarm:edit')")
    @Log(title = "客户欠费报警", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation("更新客户欠费报警")
    public AjaxResult edit(@RequestBody OverdueAlarm overdueAlarm)
    {
        return toAjax(overdueAlarmService.updateOverdueAlarm(overdueAlarm));
    }

    /**
     * 删除客户欠费报警
     */
    //@PreAuthorize("@ss.hasPermi('finance:tboverduealarm:remove')")
    @Log(title = "客户欠费报警", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    @ApiOperation("删除客户欠费报警")
    @ApiImplicitParam(name = "ids", value = "主键数组", required = true, dataType = "Long")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(overdueAlarmService.deleteOverdueAlarmByIds(ids));
    }
}
